cmake_minimum_required(VERSION 3.22)

project(camera LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()

find_package(Qt5 COMPONENTS Widgets Multimedia REQUIRED)

# 是否在aarch64 的机器上进行编译
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
    set(CMAKE_PREFIX_PATH /opt/arm-dev/)
endif()


find_package(OpenCV 4 REQUIRED)

#find_package(PkgConfig)

#find_package(OpenCV REQUIRED)
#pkg_search_module(PKG_OPENCV REQUIRED opencv4)

include_directories(${PKG_OPENCV_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} /opt/arm-dev/include/)

if(ANDROID)
  add_library(camera SHARED
    main.cpp
    mainwidget.cpp
    mainwidget.h
    mainwidget.ui
  )
else()
  add_executable(camera
    main.cpp
    mainwidget.cpp
    mainwidget.h
    mainwidget.ui

    settingdialog.h settingdialog.cpp settingdialog.ui

    camera.h camera.cpp
    recorder.h recorder.cpp
    glviewport.h glviewport.cpp
    videocapture.h videocapture.cpp
    source.qrc
  )
endif()

target_link_libraries(camera PRIVATE Qt5::Widgets Qt5::Multimedia ${PKG_OPENCV_LDFLAGS} ${OpenCV_LIBS} avcodec avformat avutil avdevice)
